// Created by lifei on 2020/7/18--8:35.
<template>
  <div class="indexMain">
    <el-row class="top mainItem">
      <el-col :span="14">
        <div class="content">
          <el-button type="primary" icon="el-icon-user-solid" circle />
          <div class="words">
            <div class="welcome">{{this.user.user.realName}}，欢迎登录！</div>
            <span>你的联系电话:{{this.user.user.phone}} | 所属部门(单位):{{this.user.user.deptName}}</span>
          </div>
        </div>
      </el-col>
    </el-row>
    <div class="conponents">
      <!-- <component :is="item" v-for="(item, index) in componentsName" :key="index" /> -->
    </div>
  </div>
</template>

<script>
import BaseLoad from '@/assets/vue-mixin/BaseLoad'
import { mapState } from 'vuex'
import { getComponents } from './module'
import path from 'path';
const files = require.context('./components', false, /\.vue$/)
const components = {}
files.keys().forEach(key => {
  const name = path.basename(key, '.vue')
  components[name] = files(key).default || files(key)
})
export default {
  components,
  computed: {
    ...mapState(['user']),
    // 组件列表
    componentsName () {
      return getComponents()
    },
  },
  mixins: [BaseLoad],
  mounted () {
    this.user.needResetPassword && this.confirmResetPassword()
  },
  beforeRouteLeave (to, from, next) {
    !['/login', '/sys-manage/edit-password'].includes(to.path) && this.user.needResetPassword ? this.confirmResetPassword() : next();
  },
  methods: {
    confirmResetPassword () {
      this.$confirm('您的密码为初始密码，根据信息安全要求，请修改为您自己定义的安全密码，并且记住修改后的密码。密码要求包含数字、大小写字母、特殊符号，修改后，请重新登录。', '提示', {
        confirmButtonText: '确定',
        type: 'warning',
        showClose: false,
        showCancelButton: false,
        closeOnClickModal: false
      }).then(() => {
        this.$router.push('/sys-manage/edit-password')
      });
    }
  },
}
</script>

<style lang='scss'>
@import "./index.scss";
</style>
